package com.ccctop.cloud.handler;

import com.ccctop.cloud.service.api.TContractAddressService;
import com.ccctop.crowd.entity.po.TContractAddress;
import com.ccctop.crowd.util.ResultEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TContractAddress)表控制层
 *
 * @author makejava
 * @since 2022-03-23 22:30:14
 */
@RestController
public class TContractAddressController {
    /**
     * 服务对象
     */
    @Resource
    private TContractAddressService tContractAddressService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("contract/selectOne")
    public ResultEntity<TContractAddress> selectContractAddressByUserId(@RequestParam("projectId") Integer projectId) {
        try{
            return ResultEntity.successWithData(this.tContractAddressService.queryByUserId(projectId));
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

    @RequestMapping("contract/insertOne")
    public ResultEntity<String> contractAddressInsertOne(@RequestBody TContractAddress contractAddress) {
        try{
            this.tContractAddressService.contractAddressInsertOne(contractAddress);
            return ResultEntity.successWithoutData();
        }catch (Exception e){
            return ResultEntity.failed(e.getMessage());
        }
    }

}